<style>
    #fenlei_box{border: 1px solid #3297ff;position: absolute;width:auto;height:250px;overflow-y: auto; z-index:9999;background:#fff;display:none;}
    #fenlei_box li{list-style: none;color:#3297ff;text-align:center;margin-left:-40px;line-height: 32px;cursor: pointer;padding-left:20px;padding-right:20px;}
</style>
<form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
    <div class="table-responsive">
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);"></td>

                <td class="text-right">
                    <a href="javascript:sort('user_id');">ID</a>
                </td>
                <td class="text-left" width="120">
                    <a href="javascript:sort('username');">会员昵称</a>
                </td>

                <td class="text-left">
                    <a href="javascript:sort('username');">姓名</a>
                </td>


                <td class="text-left">
                    <a href="javascript:void(0);">公司/店铺</a>
                </td>

                <td class="text-left">
                    <a href="javascript:sort('mobile');">手机号码</a>
                </td>

                <td class="text-left">
                    <a href="javascript:sort('mobile');">地址</a>
                </td>

                <td class="text-left">
                    <a href="javascript:sort('reg_time');">注册日期</a>
                </td>
                <td class="text-center" width="60">操作</td>
            </tr>
            </thead>
            <tbody>
            <volist name="userList" id="list">
                <tr>
                    <td class="text-center">
                        <input type="checkbox" name="selected[]" value="{$list['user_id']}">
                        <input type="hidden" name="shipping_code[]" value="flat.flat">
                    </td>
                    <td class="text-right">{$list.user_id}</td>
                    <td class="text-left">{$list.nick_name}</td>
                    <td class="text-left">{$list.nickname}</td>
                    <td class="text-left"> {$list.company}</td>

                    <td class="text-left">{$list.mobile} </td>
                    <td class="text-left">{$list.company_address} </td>
                    <!--区域设置-->




                    <td class="text-left">{$list.reg_time|date='Y-m-d H:i',###}</td>
                    <td class="text-right">
                        <a href="javascript:;" rel="{$list.user_id}"  data-toggle="tooltip" onclick="user_goods('{$list.user_id}')"  class="btn btn-primary" data-original-title="修改"><i class="fa fa-pencil"> 商品折扣管理</i></a>
                        <a href="javascript:;" rel="{$list.user_id}"  data-toggle="tooltip" onclick="user_brand('{$list.user_id}')"  class="btn btn-primary" data-original-title="修改"><i class="fa fa-pencil"> 品牌折扣管理</i></a>
<!--                        <a href="{:U('Admin/user/detail',array('id'=>$list['user_id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看详情">商品折扣管理</a>-->
<!--                        <a href="{:U('Admin/user/detail',array('id'=>$list['user_id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看详情">品牌折扣管理</a>-->
<!--                        <a href="{:U('Admin/user/address',array('id'=>$list['user_id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="收货地址"><i class="fa fa-home"></i></a>-->
                        <!--<a href="{:U('Admin/order/index',array('user_id'=>$list['user_id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="订单查看"><i class="fa fa-shopping-cart"></i></a>-->
<!--                        <a href="{:U('Admin/user/account_log',array('id'=>$list['user_id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="账户"><i class="glyphicon glyphicon-yen"></i></a>-->
<!--                        <a href="{:U('Admin/user/delete',array('id'=>$list['user_id']))}" id="button-delete6" data-toggle="tooltip" title="" class="btn btn-danger" data-original-title="删除"><i class="fa fa-trash-o"></i></a>-->
<!--                        <a href="#" onclick="addcustom({$list['user_id']})" id="addcustom" data-toggle="tooltip" title="加入公海池" class="btn btn-danger" data-original-title="加入公海池"><i class="fa fa-users"></i></a>-->
<!--                        <a href="#" onclick="addstaff({$list['user_id']})" id="addstaff" data-toggle="tooltip" title="纳入员工" class="btn btn-danger" data-original-title="纳入员工" style="padding-right: 14px;padding-left: 14px;"><i class="fa fa-user"></i></a>-->
                    </td>
                </tr>
            </volist>
            </tbody>
        </table>
    </div>
</form>
<div class="row">
    <div class="col-sm-3 text-left">
    </div>
    <div class="col-sm-6 text-right">{$page}</div>
</div>
<script>
    function user_goods(user_id){
        myrul = '/index.php/Seller/User/user_goods/user_id/'+user_id;
        $.get(myrul,function(e){
            layer.open({
                type: 2,
                shadeClose: true, //点击遮罩关闭
                title:'设置商品',
                skin: 'layui-layer-rim', //加上边框
                area: ['90%', '90%'], //宽高
                content: myrul
            });
        })
    }

    function user_brand(user_id){
        myrul = '/index.php/Seller/User/user_brand/user_id/'+user_id;
        $.get(myrul,function(e){
            layer.open({
                type: 2,
                shadeClose: true, //点击遮罩关闭
                title:'设置品牌',
                skin: 'layui-layer-rim', //加上边框
                area: ['90%', '90%'], //宽高
                content: myrul
            });
        })
    }


    $("body").on("click", function() {
        $('body #fenlei_box').hide(100);
    });

    function quyu_sousuo(obj)
    {
        var value = obj.val();
        $.ajax({
            url:"/Admin/User/quyu_sousuo?key="+value,
            success: function(data){
                if(data!=''){
                    obj.parent().find('#fenlei_box').show(100);
                    obj.parent().find('#fenlei_box').html(data);
                }else{
                    obj.parent().find('#fenlei_box').hide(100);
                }
            }
        });
    }

    function addstaff(id){
        var value = id;
        $.ajax({
            url:"/Admin/crm/addstaff?id="+value,
            success: function(data){
                var obj = JSON.parse(data);
                if(obj.code == 200){
                    alert(obj.msg);
                }else{
                    alert(obj.msg);
                }
            }
        });
    }

    function addcustom(id){
        var value = id;
        $.ajax({
            url:"/Admin/crm/addcustom?id="+value,
            success: function(data){
                var obj = JSON.parse(data);
                if(obj.code == 200){
                    alert(obj.msg);
                }else{
                    alert(obj.msg);
                }
            }
        });
    }

    $("body").on("click", function() {
        $('body #fenlei_box').hide(100);
    });

    $("body #fenlei_box").on("click","li", function() {
        var ids=$(this).attr('rev');
        var id=$(this).parent().attr('rel');
        ids=ids.split(',');
        var parent_id=ids[0];

        $.post("/Admin/User/quyu_edit",
            {
                id:id,
                parent_id:parent_id
            },
            function(data,status){
                layer.msg('推荐人设置成功！',{icon:6,time:1000});
                $('body #fenlei_box').hide(100);
            });

    });
    // 修改指定表的指定字段值
    function changeTableVal_shadow(table,id_name,id_value,field,obj)
    {
        var src = "";
        console.log($(obj).attr('src').indexOf("cancel.png"))
        if($(obj).attr('src').indexOf("cancel.png") > 0 )
        {
            src = '/Public/images/yes.png';
            var value = 0;

        }else{
            src = '/Public/images/cancel.png';
            var value = 1;
        }

        $.ajax({
            url:"/index.php?m=Admin&c=Index&a=changeTableVal&table="+table+"&id_name="+id_name+"&id_value="+id_value+"&field="+field+'&value='+value,
            success: function(data){

                $(obj).attr('src',src);
            }
        });
    }
    // 修改指定表的指定字段值
    function changeTableVal_shadow_two(table,id_name,id_value,field,obj)
    {
        var src = "";
        console.log($(obj).attr('src').indexOf("cancel.png"))
        if($(obj).attr('src').indexOf("cancel.png") > 0 )
        {
            src = '/Public/images/yes.png';
            var value = 1;

        }else{
            src = '/Public/images/cancel.png';
            var value = 2;
        }

        $.ajax({
            url:"/index.php?m=Admin&c=Index&a=changeTableVal&table="+table+"&id_name="+id_name+"&id_value="+id_value+"&field="+field+'&value='+value,
            success: function(data){

                $(obj).attr('src',src);
            }
        });
    }
    $(".pagination  a").click(function(){
        var page = $(this).data('p');
        var number = $(this).data('n');
        ajax_get_table('search-form2',page,number);
    });

    $(".page_num").change(function (){
        var number = $(this).val();
        ajax_get_table('search-form2',1,number);
    })

    //批量删除
    function datadel() {
        //获取选中的文章
        layer.confirm('确认要删除吗？',function(index){
            var inputs = $('input:checked');
            var ids ="";
            $.each(inputs,function (k,v) {
                if (v.value != ""){
                    ids += "," + v.value;
                }
            });
            $.ajax({
                type: 'GET',
                data:{
                    id:ids
                },
                url:"{:U('Admin/user/batch_delete')}",
                dataType: 'json',
                success: function(data){
                    if (data.status>0){
                        layer.msg(data.msg,{icon:1,time:1000});
                        document.location.reload();
                    }else{
                        layer.msg(data.msg,{icon:6,time:1000});
                    }

                }
            });
        } ,function(index){
            layer.close(index);
            return false;// 取消
        })
    }
</script>